
int depth(struct TreeNode* root)
{
     if(root==NULL) return 0;
     return fmax(depth(root->left),depth(root->right))+1;
}
bool isBalanced(struct TreeNode* root)
{
    if(root==NULL||root->left==NULL&&root->right==NULL) return true;
    if(fabs(depth(root->left)-depth(root->right))>1) return false;  
    return isBalanced(root->left)&&isBalanced(root->right);        
}
